#pragma once

#include <QMainWindow>
#include <QSettings>
#include <QUuid>
#include <QSet>
#include <boost/shared_ptr.hpp>

#include "ui_main_frame.h"
#include "dock_widget.h"

namespace widgets {

class MainFrame : public QMainWindow
{
  Q_OBJECT

public:
  MainFrame(QWidget *Parent_ = 0, Qt::WFlags Flags_ = 0);
  ~MainFrame();

  void select_profile(const QString &profile_name);
  void attach_model(QObject *p_model);
  void detach_model();

  void save_preferences(const QString &);
  void load_preferences(const QString &);
  // profile
  void save_profile(const QString &);
  void load_profile(const QString &);

public: // docks
  DockWidget *make_dock(const QString &widget_creator);
  DockWidget *make_dock(QWidget *p_widget, const QString &title, const QString &widget_creator, const QString &dock_uuid);

protected:
  virtual void closeEvent(QCloseEvent *);

private:
  QString get_profile_path(const QString &profile_name) const;
  void refresh_profile_menu();
  
private slots:
  void on_actionToggle_wireframe_triggered();
  void on_focus_changed(QWidget*,QWidget*);
  void on_actionOpen_triggered();
  void on_actionNew_profile_triggered();
  void on_actionSelect_profile();
  void on_actionToggle_fullscreen_triggered();
  void on_actionAbout_triggered();
  void on_make_dock();
  void on_close_dock(DockWidget *);
  void on_register_widget(const QString &);
  
  void on_vertex_action();

public:
  Ui::MainFrameClass ui;

  QString profile_dir_;
  QString profile_name_;
  QMenu *p_profile_menu_;
  QActionGroup *p_profile_action_group_;

  QObject *m_pModel;
  QWidget *p_focused_widget_;
};

} // namespace widgets
